<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body></body>
  <script>
    /* 
            Map和Set
    有序和无序？
    1.有序：操作慢 2.无序：操作快 
    Map和Object的区别？
    1.API不同，Map key可以为任意类型，2.Map是有序结构3.Map操作同样很快
   
    Set和数组的区别?
    API不同
    Set元素不能重复
    Set是无序结构，操作很快

    */

    /*  let m = new Map([
      ["a", "age"],
      ["b", "birthday"],
      ["c", "country"],
    ]);
    console.log(m, "m");
    m.set("xixi", function () {
      console.log("66");
    });
    m.set("xixi", "123");
    m.has("xixi");
    function fn() {}
    m.set(fn, "fn key");
    console.log(m.get("xixi"));
    // m.delete('xixi')
    console.log(m.size);
    for (let [key, value] of m) {
      console.log(`${key}有${value}`);
    } */

    let arr = [1, 10, 20, 30, 40, 50];
    const set = new Set([10, 40, 24, 63, 13, 64, 23]);
    console.log(set, "set");
    console.log(set.add("abc"));
    console.log(set.delete(23));
    console.log(set.has(64));
    console.log(set.size);
    set.forEach((val) => console.log(val)); //没有index
    //Set 元素是不能重复的（数组去重）
    //Set 无序结构,数组是有序的
  </script>
</html>
